package com.decorate.exampleInJDK;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class Test {
    public static void main(String[] args) throws IOException {
        //装饰者模式在jdk中的使用
        //可以看到 FileInputStream就是一个被装饰的类，BufferedInputStream就是一个包装类
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:\\test.json"));
        int len = 0;
        byte[] bytes = new byte[1024];
        while ((len = bis.read(bytes)) != -1) {
            String s = new String(bytes, 0, len);
            System.out.println(s);
        }
    }
}
